<template>
	<a-row>
		<a-row class='mytitle'>
		  <!-- <a-icon :component="share" style="margin:0 .5rem 0 0"/> -->
			{{$t('File-sharing')}}
		</a-row>
		<a-row style='margin:1em' v-userAuth="'D17'">
      <a-card hoverable>
        <a-tabs :defaultActiveKey='defaultActiveKey' @change="changeTab">
          <a-tab-pane tab="NFS" key='1'>
						<!-- v-userAuth="'D18'" -->
            <Nfs v-if="currentTabKey == '1'"></Nfs>
          </a-tab-pane>
          <a-tab-pane tab="CIFS" key='2'>
						<!-- v-userAuth="'D19'" -->
            <Cifs v-if="currentTabKey == '2'"></Cifs>
          </a-tab-pane>
        </a-tabs>
      </a-card>
    </a-row>
	</a-row>
</template>
<script>
	import Nfs from '../../../components/storage_mgr/filesharing/file_nfs'
	import Cifs from '../../../components/storage_mgr/filesharing/file_cifs'
	
	// import share from '../../../../static/images/svg/ic_filesharing_select.svg'
	import request from '@/request/request'

	export default {
	  name: "filesharing",
	  components: {Nfs,Cifs},
	  template: '<a-icon :component="share" />',
	  data(){
	    return{
	      // share,
        nfsdata:[],
				baseshare:[],
				record:[],
				mark:0,
				defaultActiveKey: '1',
				currentTabKey: '1'
	    }
	  },

		created() {
			this.currentTabKey = JSON.parse(localStorage.getItem('file_current_tab')) || '1';
      this.defaultActiveKey = JSON.parse(localStorage.getItem('file_current_tab')) || '1';
		},

	  mounted(){
		  this.getdata()
		  this.getbasedata()
	  },

		beforeDestroy() {
			localStorage.removeItem('file_current_tab');
		},

	  computed:{
			getbaseshare(){
				return this.$store.state.baseshare
			},
	  },
	  methods:{
			getdata(){
				this.loading = true
				request('get', 'cephfs/nfs').then(res=>{
					this.nfsdata = res.data
					this.loading = false
					// this.record = this.nfsdata[this.mark]
				}).catch(err => {
					this.loading = false
				})
			},

			getbasedata(){
				// this.$axios.get(this.allurl+'cephfs/nfs/_info').then(res=>{
				request('post', 'cephfs/operation/getFSAndOneDepthName').then(res=>{
					// console.log('获取nfs路径', res);
					let paths = [];
					for(let key in res.data) {
						paths = [...res.data[key]];
					}
					this.$store.commit('getbaseshare', {
						// baseshare: res.data,
						baseshare: paths,
					})
				})
			},

			// tab改变事件
			changeTab(key) {
				this.currentTabKey = key;
				localStorage.setItem('file_current_tab', JSON.stringify(key));
			},
	  }
	};
</script>

<style>
	.bigstyle{
		height: 19em;
	}
</style>
